package com.acoreful.acf2java.admin.config;

import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;

@Configuration
public class CaptchaConfig {

	/**
	 * <prop key="kaptcha.border">no</prop>
	    <prop key="kaptcha.textproducer.font.color">DARK_GRAY</prop>
	    <prop key="kaptcha.obscurificator.impl">com.google.code.kaptcha.impl.ShadowGimpy</prop>
	    <prop key="kaptcha.image.width">100</prop>
	    <prop key="kaptcha.image.height">32</prop>
	    <prop key="kaptcha.textproducer.font.size">24</prop>
	    <prop key="kaptcha.textproducer.char.length">4</prop>
	    <prop key="kaptcha.textproducer.font.names">Arial</prop>
	    <prop key="kaptcha.background.clear.from">WHITE</prop>
	    <prop key="kaptcha.background.clear.to">WHITE</prop>
	    <prop key="kaptcha.noise.impl">com.google.code.kaptcha.impl.NoNoise</prop>
	 * @return
	 */
	@Bean(name = "captchaProducer")
	public DefaultKaptcha getKaptchaBean() {
		DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
		Properties properties = new Properties();
		properties.setProperty("kaptcha.border", "yes");
		properties.setProperty("kaptcha.border.color", "105,179,90");
		properties.setProperty("kaptcha.textproducer.font.color", "blue");
		properties.setProperty("kaptcha.image.width", "125");
		properties.setProperty("kaptcha.image.height", "45");
		properties.setProperty("kaptcha.session.key", "code");
		properties.setProperty("kaptcha.textproducer.char.length", "4");
		properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
		Config config = new Config(properties);
		defaultKaptcha.setConfig(config);
		return defaultKaptcha;
	}
}
